<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改患者信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layui/layuiAdmin/css/admin.css" media="all">
    <style>
        .st{
            width: 270px!important;
        }
        .layui-form-label{
            width: 120px!important;
        }
        .xinghao{
            color: red!important;
        }
    </style>
</head>
<body>

<!--表单-->
<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
    <!--  用户ID  -->
    <div class="layui-form-item layui-hide">
        <div class="layui-input-inline st">
            <input type="text" name="patientId" lay-verify="required" class="layui-input layui-hide">
        </div>
    </div>
    <!--  手机号  -->
    <div class="layui-form-item">
        <label class="layui-form-label">手机号<span class="xinghao">*</span></label>
        <div class="layui-input-inline st">
            <input type="text" name="patientPhone" lay-verify="required|patientPhone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!--  姓名  -->
    <div class="layui-form-item">
        <label class="layui-form-label">姓名<span class="xinghao">*</span></label>
        <div class="layui-input-inline st">
            <input type="text" name="patientName" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!--  性别  -->
    <div class="layui-form-item">
        <label class="layui-form-label">性别<span class="xinghao">*</span></label>
        <div class="layui-input-inline st">
            <select name="patientSex" lay-verify="required">
                <option value="">请选择</option>
                <option value="1">男</option>
                <option value="2">女</option>
            </select>
        </div>
    </div>
    <!--   发病年龄 -->
    <div class="layui-form-item">
        <label class="layui-form-label">发病年龄</label>
        <div class="layui-input-inline st">
            <input type="number" name="morbidityAge" placeholder="发病年龄" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!--   现居住地 -->
    <div class="layui-form-item">
        <label class="layui-form-label">现居住地</label>
        <div class="layui-input-inline st">
            <select name="patientAddress" lay-verify="required">
                <option value="">请选择</option>
                <option value="北京">北京</option>
                <option value="上海">上海</option>
                <option value="广州">广州</option>
                <option value="深圳">深圳</option>
                <option value="杭州">杭州</option>
            </select>
        </div>
    </div>
    <!--   上次就诊时间 -->
    <div class="layui-form-item">
        <label class="layui-form-label">上次就诊时间</label>
        <div class="layui-input-inline st">
            <input id="mydatetime" name="lastVisitTime" placeholder="上次就诊时间" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!--   病例填写程度 -->
    <div class="layui-form-item">
        <label class="layui-form-label">病例填写程度</label>
        <div class="layui-input-inline st">
            <select name="medicalRecord" >
                <option value="">病历填写程度</option>
                <option value="1">已填写</option>
                <option value="2">未填写</option>
            </select>
        </div>
    </div>
    <!--   绑定医生 -->
    <div class="layui-form-item">
        <label class="layui-form-label">绑定医生</label>
        <div class="layui-input-inline st">
            <select name="doctorName" id="deptSelect" required>
            </select>
        </div>
    </div>
    <!--  提交 -->
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
</div>

<script src="../../../layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layui/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'layer', 'form','layedit','laydate'], function(){
        var $ = layui.$
            ,form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,layedit = layui.layedit;

        //常规用法
        laydate.render({
            elem: '#mydatetime'
        });

        // 通过后端动态获取下拉数据
        $.ajax({
            url:"/patient/getDoctor",
            type:"get",
            dataType:"json",
            success:function (res){
                // 后端获取部门数据
                var selectData = res.data;
                // 清空列表
                $("#deptSelect").empty();
                // 默认的
                $("#deptSelect").append(new Option('-请选择医生-',''));
                // 循环遍历
                $.each(selectData,function (index,item){
                    $("#deptSelect").append(new Option(item.doctorName,item.doctorId));
                })
                if(!localStorage.hasOwnProperty("doctorId")){
                    var depid = JSON.parse(localStorage.getItem("doctorId"))

                    $('#deptSelect').val(depid)
                }
                form.render('select'); // 更新渲染
            }
        })

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
        //自定义验证规则
        form.verify({
            username: function(value){
                // 限制用户名是3~16字符
                var reg = /^[a-zA-Z][a-zA-Z0-9_]{2,15}$/;
                if(!reg.test(value)){
                    return '字母开头，允许3-16字符，允许字母数字下划线';
                }
            },
            mobile: function(value){
                // 限制手机号码
                var reg = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|17[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9]|19[0|1|2|3|5|6|7|8|9])\d{8}$/;
                if(!reg.test(value)){
                    return '手机号码格式不正确';
                }
            }
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

    })
</script>
</body>
</html>